package com.chanzany.prototype;

public class ProtoTypeCitation {
    public static void main(String[] args)  {
        Citation citation = new Citation("张三", "同学：在2021学年第一学期中表现优秀，被评为三好学生。", "向日葵小学");
        citation.display();
        Citation citation2 = citation.clone();
        citation2.setName("李四");
        citation2.display();
    }
}

class Citation implements Cloneable{
    String name;
    String info;
    String college;

    public Citation(String name, String info, String college) {
        this.name = name;
        this.info = info;
        this.college = college;
        System.out.println("奖状创建成功！");
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
    public void display(){
        System.out.println(name+info+college);
    }

    @Override
    protected Citation clone() {
        Citation citation = null;
        try {
            citation = (Citation) super.clone();
            System.out.println("奖状拷贝成功!");
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return citation;
    }
}